
var SwakFunMode = {
	swakFunIgnoreComments: new Array(),

getFunComment: function() {
	var comment = 'Mindstorm thinks he is funny...well, he\'s right';
	var customFun = SS_getPreference(SMACK_ENABLE_FUNLIST);
	try {
		if (customFun && this.swakFunIgnoreComments != null && this.swakFunIgnoreComments.length>0) {
			var rn = SS_getRandomNumber(this.swakFunIgnoreComments.length-1);
			comment = this.swakFunIgnoreComments[rn];
		}
		else {
		var rn = SS_getRandomNumber(20);
		comment = SS_getStringTableText("ignore_fun"+rn);
		
		}
	}
	catch(x) {}
	
	return comment;
},

 initFunMode: function() {
	var fileName = SS_getPreference(SMACK_FUNLIST_FILE);
	var result = this.loadFunIgnoreFile(fileName);
},

loadFunIgnoreFile: function(fileName) {
	if (fileName == null || fileName == '') return;
		var f = null;
		try {
			if (fileName.substring(0,7) == "file://") {
		     // if this is a URL, get the file from that
		     var ioSvc = Components.classes["@mozilla.org/network/io-service;1"].
		                 getService(Components.interfaces.nsIIOService);
		 
		     // XXX it's possible that using a null char-set here is bad
		     const fileUrl = ioSvc.newURI(fileName, null, null).QueryInterface(Components.interfaces.nsIFileURL);
		     f =  fileUrl.file.clone().QueryInterface(Components.interfaces.nsILocalFile);
		   } 
		   else {
		     // if it's a pathname, create the nsILocalFile directly
		      f = new nsLocalFile(fileName);
		 
		    
		   }
		  // alert('f ' +f);
		   var istream = Components.classes["@mozilla.org/network/file-input-stream;1"]
		                        .createInstance(Components.interfaces.nsIFileInputStream);
			istream.init(f, 0x01, 0444, 0);
			istream.QueryInterface(Components.interfaces.nsILineInputStream);
			
			// read lines into array
			this.swakFunIgnoreComments = [];
			var line = {}, hasmore;
			do {
			  hasmore = istream.readLine(line);
			  if (line.value != '') {
			  	this.swakFunIgnoreComments.push(line.value); 
				}
			} while(hasmore);
			
			istream.close();
			
			//alert(this.swakFunIgnoreComments);
			//alert('swakFunIgnoreComments len ' + this.swakFunIgnoreComments.length);
			return true;		
	}
	catch (x) {
		return false;
	}
	return false;
 }
 


}